#include <iostream>
#include <string>
using namespace std;

void replaceAll(string &s, const string &oldVal, const string &newVal) {
    size_t pos = 0;
    while ((pos = s.find(oldVal, pos)) != string::npos) {
        s.replace(pos, oldVal.length(), newVal);
        pos += newVal.length();
    }
}

int main() {
    string text = "I tho these shortcuts are so helpful thru this book.";
    
    replaceAll(text, "tho", "though");
    replaceAll(text, "thru", "through");

    cout << "Replaced text: " << text << std::endl;

    return 0;
}
